/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.tfile;

import java.io.FileOutputStream;
import java.net.Socket;
import java.util.UUID;

/**
 * <p>Project: jse2303 - FileClient</p>
 * <p>Powered by webrx On 2023-07-26 14:04:37</p>
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class FileClient {
    public static void main(String[] args) {

        try {
            Socket c = new Socket("192.168.21.6", 8888);
            //读取
            var is = c.getInputStream();
            String ff = System.getProperty("user.home").concat("/Desktop/").concat(UUID.randomUUID().toString()).concat(".jpg");
            var os = new FileOutputStream(ff);
            byte[] buf = new byte[1024];
            int len = 0;
            while ((len = is.read(buf)) > 0) {
                os.write(buf, 0, len);
            }

        } catch (Exception e) {

        }
    }
}
